package be.bejug.setris.blocks

import be.bejug.setris.{Tiles, Tile, TileGrid}
import util.Random

/**
 * Defines all the blocks used in a classic Tetris Game
 */
object	Blocks{
	val	allBlocks	=	List(
		new BlockI(Tiles.cyan),
		new	BlockJ(Tiles.blue),
		new	BlockL(Tiles.orange),
		new	BlockO(Tiles.yellow),
		new	BlockS(Tiles.green),
		new	BlockT(Tiles.magenta),
		new	BlockZ(Tiles.red)
	)


//####
	class	BlockI(tile:Tile) extends TileGrid(4,1,
		Map(
			(0,0)->tile,
			(1,0)->tile,
			(2,0)->tile,
			(3,0)->tile
		)
	)
//###
//  #
	class BlockJ(tile:Tile) extends TileGrid(3,2,
		Map(
			(0,0)->tile,
			(1,0)->tile,
			(2,0)->tile,
			(2,1)->tile
		)
	)
//###
//#
	class BlockL(tile:Tile) extends TileGrid(3,2,
		Map(
			(0,0)->tile,
			(0,1)->tile,
			(1,0)->tile,
			(2,0)->tile
		)
	)
//##
//##
	class	BlockO(tile:Tile) extends TileGrid(2,2,
		Map(
			(0,0)->tile,
			(1,0)->tile,
			(0,1)->tile,
			(1,1)->tile
		)
	)
// ##
//##
	class BlockS(tile:Tile) extends TileGrid(3,2,
		Map(
			(1,0)->tile,
			(2,0)->tile,
			(0,1)->tile,
			(1,1)->tile
		)
	)
// #
//###
	class BlockT(tile:Tile) extends TileGrid(3,2,
		Map(
			(1,0)->tile,
			(0,1)->tile,
			(1,1)->tile,
			(2,1)->tile
		)
	)

//##
// ##
	class BlockZ(tile:Tile) extends TileGrid(3,2,
		Map(
			(0,0)->tile,
			(1,0)->tile,
			(1,1)->tile,
			(2,1)->tile
		)
	)

  def randomBlock = allBlocks(new Random().nextInt(allBlocks.size))
}
